/**
 * Created by lgc on 2017/10/28.
 */
import Vue from 'vue'
import Vuex from 'vuex'
import * as actions from './actions'
import * as getters from './getters'
import home from './modules/home'
import login from './modules/login'
import app from './modules/app'
import * as types from './mutation-types'

Vue.use(Vuex);

/*const debug = process.env.NODE_ENV !== 'production';*/
const debug = false;
export default new Vuex.Store({
  state: {
    user: {},
    token: null,
    title: '',
    tagsList:[],
    menuList:[],
  },
  actions,
  getters,
  modules: {
    home,
    login,
    app
  },
  mutations: {
    [types.LOGIN]: (state, data) => {
      localStorage.token = data;
      state.token = data;
    },
    [types.LOGOUT]: (state) => {
      localStorage.removeItem('token');
      state.token = null
    },
    [types.TITLE]: (state, data) => {
      state.title = data;
    },
    setAvator (state, path) {
      localStorage.avatorImgPath = path;
    }
  },
  strict: debug
})
